<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<style>
.input2 {
	border: 1px solid #C8C8C8;
	padding: 3px 5px;
}
.wrc {width:250px;}
.td_label
{
	background: #efefef;
}
.order-tb td {padding: 3px 5px}
img#loading {display:none}
.order-border
{
	border: 1px solid #ccc;
	background: #ffffff;
	width: 65%; margin: 0 auto;
	padding: 20px 10px;
}
</style>
<div class="page-content middle padtop10">
	<!-- bread crumb -->
	<p id="bread-crumb">
		<a href="<?php echo site_url('');?>">
			<?php echo $lang['home'];?>
        </a>
        <a href="<?php echo site_url('recharge');?>">
			<?php echo $lang['request_recharge'];?>
		</a>
		<?php echo $row->createname;?>
	</p>
	<!-- end bread crumb -->
	<h3>
		<?php echo $lang['request_recharge'];?>
	</h3>
	<br />
	<div class="payment-total-info myclear">
		<div class="order-border">
			<table width="100%" style="border-spacing:1px" class="order-tb">
				<tr>
					<td class="td_label">
						<b><?php echo $lang['create_account'];?></b>
					</td>
					<td>
						<b><?php echo $row->createname;?></b>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['group_name'];?></b>
					</td>
					<td>
						<b><?php echo $row->groupname;?></b>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['type_user'];?></b>
					</td>
					<td>
						<?php echo ($row->typeuser == 0 ? $lang['user_real'] : $lang['acc_agency']);?>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['recieve_account'];?></b>
					</td>
					<td>
						<b><?php echo $row->recievename;?></b>
					</td>
				</tr>
				<tr>
					<td width="150" class="td_label">
						<b><?php echo $lang['amount'];?></b>
					</td>
					<td>
						<b><?php echo number_format($row->money);?> (đ)</b>
					</td>
				</tr>
				<tr>
					<td width="150" class="td_label">
						<b><?php echo $lang['confirm'];?></b>
					</td>
					<td>
						<b><?php echo number_format($row->real_money);?> (đ)</b>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<?php echo $lang['content'];?>
					</td>
					<td>
						<?php echo $row->content;?>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['style_recharge'];?></b>
					</td>
					<td>
						<?php echo $row->typepay;?>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['receipts'];?></b>
					</td>
					<td>
						<?php echo $row->receipts;?>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['comment'];?></b>
					</td>
					<td>
						<p><?php echo $row->description;?></p>
						<textarea class="input2 wrc" style="height:50px" name="txtDes"></textarea>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['date'];?></b>
					</td>
					<td>
						<input type="text" readonly="true" class="input-time" id="date" value="<?php echo date('Y-m-d');?>" style="width:100px" />
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['status'];?></b>
					</td>
					<td>
						<span style="color:<?php switch($row->status){case -1:case 0:echo 'red';break;case 2:echo 'blue';break;case 1: echo 'green';break;}?>">
							<b><?php echo (array_key_exists($row->status, $lang['arr_status']) ? $lang['arr_status'][$row->status] : '');?></b>
						</span>
					</td>
				</tr>
				<tr>
					<td class="td_label">
						<b><?php echo $lang['logs'];?></b>
					</td>
					<td>
						<?php echo $row->logs;?>
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td class="text-right">
						<br /><div id="mes" class="text-left" style="color:#ff0000"></div>
						<br /><br />
						<input class="input2" type="button" value="<?php echo $lang['recharge'];?>" onclick="rechargeUpdate(2);" <?php if($row->status != 1) echo 'disabled="disabled"';?> />
						<input class="input2" type="button" value="<?php echo $lang['cancel'];?>"  onclick="rechargeUpdate(-1);" <?php if($row->status == 2 || $row->status == -1) echo 'disabled="disabled"';?> />
						<input class="input2" type="button" value="<?php echo $lang['re_comfirm'];?>" onclick="rechargeUpdate(0);" <?php if($row->status == 2) echo 'disabled="disabled"';?> />
						<input class="input2" type="button" value="<?php echo $lang['back'];?>" onclick="window.location = '<?php echo site_url('recharge/adlist/?status='.$row->status.'&typead='.$typead);?>';" />
					</td>
				</tr>
			</table>
		</div>
	</div>
</div>
<br />
<br />
<script type="text/javascript">
var _processing = false;
$('#date').DatePicker({
	format:'Y-m-d',
	current: $('#date').val(),
	date: $('#date').val(),
	start: 1,
	position: 'bottom',
	onChange: function(formated, dates){
		$('#date').val(formated);
		$('#date').DatePickerHide();
	}
});
function rechargeUpdate(status)
{
	if(_processing) return false;
	if(!confirm('<?php echo $lang['confirm_action'];?>')) return false;
	_processing = true;	//flag dang xu ly
	$des = $.trim($('textarea[name="txtDes"]').val());
	$date = $('#date').val();
	if((status == -1 || status == 0) && $des.length == 0)
	{
		alert('<?php echo $lang['enter_comment'];?>');
		_processing = false;
		return false;
	}
	$('#mes').html('<img src="/images/ajaxLoading.gif" border="0" />');
	$.ajax({
		type: 'post',
		url: '<?php echo site_url('recharge/adupdatestatus');?>',
		data: {status: status, des: $des, id: <?php echo $row->id;?>, date: $date},
		success: function(data){
			if(data == '1')
			{
				$('#mes').html('<?php echo $lang['update_status_success'];?>');
				setTimeout('window.location.href="<?php echo site_url('recharge/adlist/?status='.$row->status.'&typead='.$typead);?>";', 5000);
			}
			else
			{
				$('#mes').html(data);
				_processing = false;
			}
		}
	});
}
</script>